import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)

  const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home
  }, {
      path: '/city',
      name: 'city',
      component: () => import('../views/City.vue')
  }, {
      path: '/detail/:id',
      name: 'detail',
      component: () => import('../views/Detail.vue')
  }
]

const router = new VueRouter({
    routes,
    /* 滚动时不影响其他界面 */
    scrollBehavior (to, from, savedPosition) {
      if (savedPosition) {
        return savedPosition
      } else {
        return { x: 0, y: 0 }
      }
    }
})

export default router
